#include <iostream>
#include "../thread_pool.h"

int main()
{
    uint32_t cnt[4] = {0,0,0,0};
    THREADPOOL::ThreadPool thread_pool(4);
    std::atomic<bool> running = true;

    thread_pool.enqueue([&cnt, &running]
    {
        while (running)
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(1000));
            std::cout << "Thread 1 is running ...  " << ++cnt[0] <<std::endl;
        }
    });

    thread_pool.enqueue([&cnt, &running]
    {
        while (running)
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(1500));
            std::cout << "Thread 2 is running ...  " << ++cnt[1] <<std::endl;
        }
    });

    thread_pool.enqueue([&cnt, &running]
    {
        while (running)
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(2000));
            std::cout << "Thread 3 is running ...  " << ++cnt[2] <<std::endl;
        }
    });

    thread_pool.enqueue([&cnt, &running]
    {
        while (running)
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(4000));
            std::cout << "Thread 4 is running ...  " << ++cnt[3] <<std::endl;
        }
    });

    getchar();
    running = false;

    return 0;
}